package com.greedy.hateoas.demo.stock.startup;

import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

/**
 * @Author: Yanxy
 * @Date: Created in:2023-07-12
 * Description: 启动类
 */
@SpringBootApplication()
@ComponentScan(basePackages = {"com.greedy"})
@EntityScan(basePackages = {"com.greedy"})
@EnableJpaRepositories(basePackages = {"com.greedy"})
@EnableCaching
public class HateoasStocksApp {

    /**
     * main方法
     */
    public static void main(String[] args) {
        SpringApplication.run(HateoasStocksApp.class, args);
    }

    /**
     * 配置Hibernate5Module
     *
     * @return Hibernate5Module
     */
    @Bean
    public Hibernate5Module hibernate5Module() {
        return new Hibernate5Module();
    }

    /**
     * 初始化Jackson2ObjectMapperBuilderCustomizer
     *
     * @return Jackson2ObjectMapperBuilderCustomizer
     */
    @Bean
    public Jackson2ObjectMapperBuilderCustomizer jacksonBuilderCustomizer() {
        return builder -> builder.indentOutput(true);
    }

}
